package com.youbug.mall.member_ums.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.member_ums.entity.UmsMemberReceiveAddress;
import com.youbug.mall.member_ums.service.IUmsMemberReceiveAddressService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员收货地址 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-07-06
 */
@RestController
@RequestMapping("/umsMemberReceiveAddress")
public class UmsMemberReceiveAddressController {
@Autowired
private IUmsMemberReceiveAddressService umsMemberReceiveAddressService;

    @PostMapping("/getUmsMemberReceiveAddressPage")
    public R<IPage<UmsMemberReceiveAddress>> getUmsMemberReceiveAddressPage(@RequestBody QueryVo<UmsMemberReceiveAddress> queryVo){

        IPage<UmsMemberReceiveAddress> umsMemberReceiveAddresss = umsMemberReceiveAddressService.getUmsMemberReceiveAddressPage(queryVo);

        return R.ok(umsMemberReceiveAddresss);
    }

    @GetMapping("/getUmsMemberReceiveAddressById/{id}")
    public R<UmsMemberReceiveAddress> getUmsMemberReceiveAddressById(@PathVariable Integer id){

        UmsMemberReceiveAddress umsMemberReceiveAddress = umsMemberReceiveAddressService.getById(id);

        return R.ok(umsMemberReceiveAddress);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody UmsMemberReceiveAddress umsMemberReceiveAddress){

        boolean save = umsMemberReceiveAddressService.save(umsMemberReceiveAddress);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody UmsMemberReceiveAddress umsMemberReceiveAddress){

        boolean update = umsMemberReceiveAddressService.updateById(umsMemberReceiveAddress);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = umsMemberReceiveAddressService.removeById(id);

        return  R.ok(remove);
    }
}

